﻿package core.ui.controls
{
    import core.enum.*;
    import core.image.*;
    import flash.display.*;
    import flash.geom.*;
    import flash.text.*;

    public class BrushInfo extends Sprite
    {
        public var nr:int;
        public var size:int;
        public var thumb:Bitmap;
        public var shape:Brush;
        private var bg:Sprite;
        private var lb:TextField;

        public function BrushInfo(param1:Brush)
        {
            this.shape = param1;
            var _loc_2:* = new Matrix();
            _loc_2.createGradientBox(33, 43, 90 / (180 / Math.PI), 0, 0);
            this.bg = new Sprite();
            this.bg.graphics.beginFill(1085418);
            this.bg.graphics.drawRect(0, 0, 35, 45);
            this.bg.graphics.beginGradientFill("linear", [6273533, 34534], [1, 1], [0, 255], _loc_2);
            this.bg.graphics.drawRect(1, 1, 33, 43);
            this.bg.graphics.endFill();
            this.bg.alpha = 0;
            addChild(this.bg);
            this.thumb = new Bitmap(param1.GenerateThumb(29));
            this.thumb.x = Math.round((35 - this.thumb.width) / 2);
            this.thumb.y = Math.round((35 - this.thumb.height) / 2);
            addChild(this.thumb);
            this.lb = new TextField();
            this.lb.defaultTextFormat = new TextFormat("Verdana, Helvetica, San-serif", 11, 0, false, false, false, null, null, "center");
            this.lb.selectable = false;
            this.lb.width = 35;
            this.lb.y = 29;
            this.lb.text = param1.type != BrushType.Custom ? ((param1.details.radius * 2).toString()) : (param1.size.toString());
            addChild(this.lb);
            return;
        }// end function

        public function Marking(toString:Boolean) : void
        {
            var _loc_2:ColorMatrix = null;
            if (toString && this.bg.alpha == 0 || !toString && this.bg.alpha == 1)
            {
                _loc_2 = new ColorMatrix();
                _loc_2.Invert();
                this.thumb.bitmapData.applyFilter(this.thumb.bitmapData, this.thumb.bitmapData.rect, this.thumb.bitmapData.rect.topLeft, _loc_2.filter);
                if (toString)
                {
                    this.bg.alpha = 1;
                    this.lb.textColor = 16777215;
                }
                else
                {
                    this.bg.alpha = 0;
                    this.lb.textColor = 0;
                }
            }
            return;
        }// end function

        public function get marked() : Boolean
        {
            return Boolean(this.bg.alpha == 1);
        }// end function

    }
}
